<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use Illuminate\Support\Facades\Response;
class UploadController extends BaseController
{
    public function companyLogo(Request $request)
    {

        $img = $request->input('dataURL','');

        if(empty($img)){
            return Response::json(array('status'=>'fail','msg'=>'图像不能为空！'));
    }
        if (strstr($img,",")){
            $img = explode(',',$img);
            $img = $img[1];
        }
        $imageName = $this->user->old_corp_no;
        $logo = "/uploads/images/company-logo/".$imageName.'.png';
        $r = file_put_contents(public_path($logo), base64_decode($img));
        if (!$r) {
            return Response::json(array('status'=>'fail','msg'=>'图像上传失败！'));
        }else{
            return Response::json(array('status'=>'success','data'=>$logo,'msg'=>'头像上传成功！'));
        }
    }
}
